home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1997 May
/
EnigmA AMIGA RUN 18 (1997)(G.R. Edizioni)(IT)[!][issue 1997-05][EAR-CD II].iso
/
softwareupdate
/
system
/
amigados
/
amigadoslibrary
/
openfromlock.c
< prev
next >
Wrap
C/C++ Source or Header
|
1996-10-10
|
1KB
|
57 lines
/* OpenFromLock.c V1.0 93-03-15 */
/* ROM library: "dos.library/OpenFromLock", (V36+) */
/* Copyright 1993, Anders Bjerin, Amiga C Club */
#include <dos/dos.h>
#include <clib/dos_protos.h>
#include <stdio.h>
#include <stdlib.h>
UBYTE *version = "$VER: OpenFromLock 1.0";
int main( int argc, char *argv[] );
int main( int argc, char *argv[] )
{
BPTR my_lock;
BPTR my_file;
/* Put an exclusive lock on an existing file: */
my_lock = Lock( "RAM:Score.dat", EXCLUSIVE_LOCK );
/* OK? */
if( !my_lock )
{
/* Error! Could not lock the file! */
printf( "Could not put an exclusive lock on the file!\n" );
exit( 20 );
}
printf( "File exclusively locked!\n" );
/* Open the file with help of the lock we already have: */
my_file = OpenFromLock( my_lock );
/* OK? */
if( !my_file )
{
/* Problems! Could not open the file! */
printf( "Error! Could not open the file!\n" );
UnLock( my_lock );
exit( 21 );
}
printf( "File open!\n" );
/* - - - */
/* Close the file: */
Close( my_file );
/* Unlock the file: */
UnLock( my_lock );
printf( "File closed and unlocked!\n" );
exit( 0 );
}